WELCOME TO MY SITE. THIS SITE HAS BEEN CREATED BY MD RIAZ & IS FOR TRAIL ONLY. THANK YOU.
  • Home
  • HTML Steps »
    • HTML Doctypes
    • HTML Layout
    • HTML Head
    • HTML Meta
    • HTML Script
    • HTML URL
    • HTML Validation
  • HTML Advenced »
    • HTML Doctypes
    • HTML Layout
    • HTML Head
    • HTML Meta
    • HTML Script
    • HTML URL
    • HTML Validation
  • HTML References »
    • HTML Character Entities
    • List of HTML5 Tags/Elements
  • Contact »
    • Facebook
    • Email

H T M L Layout


Web page layout is an essential part of creating well-formed, well-structured, semantically-rich websites.

Creating Website Layouts

Creating a website layout is the activity of positioning the various elements that make a web page in a well-structured manner and give appealing look to the website. You can find, most of the websites on the internet have put their content in multiple rows and columns — formatted like a magazine or newspaper, to give general web users a better reading and writing environment. This can be easily achieved by using the <table>, <div> or <span> tags and adding some styles to them.

HTML Layout Using Tables

Tables are the simplest method for creating layouts in HTML. Generally, this involves the process of putting the content into rows and columns. The following HTML layout is achieved using a table with 3 rows and 2 columns — the first and last row spans both columns using the colspan attribute:

Example

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>HTML Table Layout</title>
  6. </head>
  7. <body style="margin:0px;">
  8.     <table cellpadding="10px;" cellspacing="0" style="font:12px verdana, sans-serif; width:100%;">
  9.         <tr>
  10.             <td colspan="2" style="background-color:#679BB7;">
  11.                 <h1 style="font-size:18px; margin:10px 0;">MYHTML</h1>
  12.             </td>
  13.         </tr>
  14.         <tr style="height:170px;">
  15.             <td style="background-color:#bbd2df; width:20%; vertical-align:top;">
  16.                 <ul style="list-style:none; padding:0px; margin:0px;">
  17.                     <li style="margin-bottom:5px;"><a href="#" style="color:#3d677e;">Home</a></li>
  18.                     <li style="margin-bottom:5px;"><a href="#" style="color:#3d677e;">About</a></li>
  19.                     <li style="margin-bottom:5px;"><a href="#" style="color:#3d677e;">Contact</a></li>
  20.                 </ul>
  21.             </td>
  22.             <td style="background-color:#f0f0f0; width:80%; vertical-align:top;">
  23.                 <h2 style="font-size:16px; margin:0px;">Welcome to our site</h2>
  24.                 <p>Here you will learn to create websites...</p>
  25.             </td>
  26.         </tr>
  27.         <tr>
  28.             <td colspan="2" style="background-color:#679BB7;">
  29.                 <p style="text-align:center; margin:5px;">copyright &copy; myyhtml.mywebcommunity.org</p>
  30.             </td>
  31.         </tr>
  32.     </table>
  33. </body>
  34. </html>

— The HTML code above will produce the following output:

HTML Table Layout

MYHTML

  • Home
  • About
  • Contact

Welcome to our site

Here you will learn to create websites...

copyright © myyhtml.mywebcommunity.org

Warning:The method used for creating layout in the above example is not wrong, but it's not recommended. Avoid tables and inline styles for creating layout.

HTML Layouts Using Div and Span

The HTML <div> (stands for division) element is used for marking out a block of content, or set of other elements inside an HTML document. It can contain further div element if required, but it cannot be contained within an inline element. The <span> element on the other hand is used for marking out sections within a block element or other inline elements.

The following example uses the div elements to create a multiple column layout, producing the same result as in the previous example that uses tables:

Example

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>HTML Table Layout</title>
  6. </head>
  7. <body style="margin:0px;">
  8.     <table cellpadding="10px;" cellspacing="0" style="font:12px verdana, sans-serif; width:100%;">
  9.         <tr>
  10.             <td colspan="2" style="background-color:#679BB7;">
  11.                 <h1 style="font-size:18px; margin:10px 0;">MYHTML</h1>
  12.             </td>
  13.         </tr>
  14.         <tr style="height:170px;">
  15.             <td style="background-color:#bbd2df; width:20%; vertical-align:top;">
  16.                 <ul style="list-style:none; padding:0px; margin:0px;">
  17.                     <li style="margin-bottom:5px;"><a href="#" style="color:#3d677e;">Home</a></li>
  18.                     <li style="margin-bottom:5px;"><a href="#" style="color:#3d677e;">About</a></li>
  19.                     <li style="margin-bottom:5px;"><a href="#" style="color:#3d677e;">Contact</a></li>
  20.                 </ul>
  21.             </td>
  22.             <td style="background-color:#f0f0f0; width:80%; vertical-align:top;">
  23.                 <h2 style="font-size:16px; margin:0px;">Welcome to our site</h2>
  24.                 <p>Here you will learn to create websites...</p>
  25.             </td>
  26.         </tr>
  27.         <tr>
  28.             <td colspan="2" style="background-color:#679BB7;">
  29.                 <p style="text-align:center; margin:5px;">copyright &copy; myyhtml.mywebcommunity.org</p>
  30.             </td>
  31.         </tr>
  32.     </table>
  33. </body>
  34. </html>

— The HTML code above will produce the same output as the previous example:

HTML Table Layout

MYHTML

  • Home
  • About
  • Contact

Welcome to our site

Here you will learn to create websites...

copyright © myyhtml.mywebcommunity.org

Tip:Better layouts can be created by using DIV, SPAN and CSS. You can change the layout of all the pages of your website by just editing a CSS file.


Creating Website Layouts Using HTML5 Structural Elements

HTML5 has introduced new structural elements like <header>, <footer>, <nav>, <section> etc. to define different parts of the web pages in a more semantic way. You can consider these elements as a replacement for commonly used classes such as .header, .footer, .nav, .section etc. The following example uses the new HTML5 structural elements to create the same web page layout what we have created in the previous examples.

Example

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>HTML Table Layout</title>
  6. </head>
  7. <body style="margin:0px;">
  8.     <table cellpadding="10px;" cellspacing="0" style="font:12px verdana, sans-serif; width:100%;">
  9.         <tr>
  10.             <td colspan="2" style="background-color:#679BB7;">
  11.                 <h1 style="font-size:18px; margin:10px 0;">MYHTML</h1>
  12.             </td>
  13.         </tr>
  14.         <tr style="height:170px;">
  15.             <td style="background-color:#bbd2df; width:20%; vertical-align:top;">
  16.                 <ul style="list-style:none; padding:0px; margin:0px;">
  17.                     <li style="margin-bottom:5px;"><a href="#" style="color:#3d677e;">Home</a></li>
  18.                     <li style="margin-bottom:5px;"><a href="#" style="color:#3d677e;">About</a></li>
  19.                     <li style="margin-bottom:5px;"><a href="#" style="color:#3d677e;">Contact</a></li>
  20.                 </ul>
  21.             </td>
  22.             <td style="background-color:#f0f0f0; width:80%; vertical-align:top;">
  23.                 <h2 style="font-size:16px; margin:0px;">Welcome to our site</h2>
  24.                 <p>Here you will learn to create websites...</p>
  25.             </td>
  26.         </tr>
  27.         <tr>
  28.             <td colspan="2" style="background-color:#679BB7;">
  29.                 <p style="text-align:center; margin:5px;">copyright &copy; myyhtml.mywebcommunity.org</p>
  30.             </td>
  31.         </tr>
  32.     </table>
  33. </body>
  34. </html>

HTML Table Layout

MYHTML

  • Home
  • About
  • Contact

Welcome to our site

Here you will learn to create websites...

copyright © myyhtml.mywebcommunity.org






How Many People Visit

​